#!/usr/bin/python
# Filename: backup_ver2.py
# TODO: use os.sep instead of '/'

import os, time

source = [ '/home/liubin/mysrc/script/python/learn_a_byte_of_python', '/home/liubin/mysrc/script/bash' ]
target_dir = '/home/liubin/data/'

now = time.strftime( "%Y%m%d" )
if not os.path.exists( target_dir + '/' + now ):
	os.mkdir( target_dir + '/' + now )

filename = time.strftime( "%H%M%S" ) + ".zip"
target = target_dir + '/' + now + '/' + filename;
zip_cmd = "zip -qr '%s' %s" % (target, ' '.join( source ) )

print zip_cmd

if os.system( zip_cmd ) == 0:
	print 'Success backup to', target
else:
	print 'Backup failed'

